Skip to content

Studio: npm run check runs the real git, past macOS's xcrun stub (#803) - #817

Merged
danielrispler merged 3 commits into
mainfrom
issue-803-fast-git
Nov 28, 2026
Merged

danielrispler merged 3 commits into
mainfrom
issue-803-fast-git

Conversation

@danielrispler

Copy link
Copy Markdown
Owner

Refs #803. Leaves it open: it stays the log for later loads.

Summary

On this Mac, /usr/bin/git is first on PATH, and it is a stub that runs xcrun on every call to find Xcode's git. A check's tests make about 18,000 git calls, and those calls were 78% of the test run's CPU (measurements in #803). npm run check now hands its steps a PATH with the real git ahead of the stub.

 slot.mjs  (npm run check)
   take a slot
-  spawn npm run check:steps
+  spawn npm run check:steps, with env.PATH = gitPath(PATH)
+
+gitPath(PATH)
+  not macOS                              -> PATH unchanged
+  first git on PATH is not /usr/bin's    -> PATH unchanged (Homebrew's, a test's fake)
+  xcrun -f git fails                     -> PATH unchanged
+  else insert dirname(xcrun -f git) right before /usr/bin

It goes right before /usr/bin, not at the front, so every folder before /usr/bin (node_modules/.bin, a test's fake bin) keeps its place. Xcode's folder holds 115 other tools. Those also pass over only /usr/bin's stubs, which run the same tools.

Documented in docs/studio/development.md, in the check-slot paragraph.

Evidence

  • Before: ui/tests/check-slot.test.mjs, the new table the wrapped command's git, with <kind> first on PATH. Its row PATH=<dir>:/usr/bin:/bin expects <xcrun -f git> <dir>, and before the change it failed:
    expected: '/Applications/Xcode.app/Contents/Developer/usr/bin/git'
    actual: '/usr/bin/git'
    
    A first version put Xcode's folder at the front of PATH. The row's second field (the first folder must stay <dir>) catches that version too.
    After: both rows pass: the stub row, and a fake git before the stub, which stays first. npm run check is green: 2,007 Rust tests and 847 node tests, 1 skipped (an existing skip, not these rows).
  • Cost per call (git rev-parse, 200 calls, CPU via wait4): /usr/bin/git 6.4-7.4 ms, Xcode's git 2.3 ms.
  • studio-system-map::it, A/B with Xcode's git first on PATH: CPU 130 → 85 s and 101 → 71 s; wall 49 → 26 s and 30 → 20 s. The Mac was loaded (load 10-19) and these are two pairs, so treat them as about 30%, not as exact figures.
  • Whole check on this branch: 144 s wall, 177 s user, 144 s sys; nextest took 79 s. That can't be compared with Studio: CPU load from checks and tests, after the check slots (#778) #803's 152 s user + 152 s sys baseline: that was measured on another day, with other checks on the machine. So no whole-check gain is claimed here.

Merge Danger

Door: two-way

A revert of one file puts PATH back.

Blast Radius: checks

Only npm run check on macOS changes, and only when /usr/bin/git would be found first. The steps then run Xcode's git (and Xcode's other tools in place of their /usr/bin stubs), the same binaries the stubs run, without xcrun in front. npm run check:steps, direct cargo nextest runs and the plotkeeper server's own git calls are unchanged and still go through the stub. The bigger cut, fewer temporary git repos per test case (#803, fix direction 1), is not in this PR.

Correctness pass

Not run: the PR changes JavaScript (.mjs) and Markdown, no Rust or TypeScript.

Outside review

skipped: no risk match

🤖 Generated with Claude Code

danielrispler and others added 3 commits November 28, 2026 17:54
…the xcrun stub (#803)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ATH folders keep their place (#803)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@danielrispler
danielrispler merged commit 92c2640 into main Nov 28, 2026
3 of 4 checks passed
@danielrispler
danielrispler deleted the issue-803-fast-git branch November 28, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant